const Router = require('koa-router')
const router = new Router({ prefix: '/topic' })
const jwt = require('koa-jwt')
const { find, findById, update, create, listTopicFollower, checkTopicExist, listQuestions } = require('../controlles/topics')
const { secret } = require('../config')

const auth = jwt({ secret })
router.get('/', find)
router.get('/:id', checkTopicExist,  findById)
router.post('/', auth,create)
router.patch('/:id', auth, checkTopicExist, update)
router.get('/:id/follower', checkTopicExist, listTopicFollower)
router.get('/:id/question', checkTopicExist, listQuestions)

module.exports = router